<template>
  <div>
    <el-form :model="form" label-width="120px">
      <el-form-item label="角色名称：">
        <el-input class="input" v-model="form.name" size="small"></el-input>
      </el-form-item>
      <el-form-item label="描述：">
        <el-input class="input" v-model="form.name" type="textarea" size="small"></el-input>
      </el-form-item>
      <el-form-item label="角色权限：">
        <el-tree :data="data" show-checkbox default-expand-all node-key="id" ref="tree" highlight-current
        :props="defaultProps">
      </el-tree>
      </el-form-item>

      
      <el-form-item label="状态：">
        <el-radio-group v-model="radio">
          <el-radio :label="3">启用</el-radio>
          <el-radio :label="6">禁用</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button size="small">取消</el-button>
        <el-button type="primary" size="small">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  import RichText from "@/components/RichText"
  export default {
    components: {
      RichText
    },
    data() {
      return {
        data: [
          {
            id: 1,
            label: '一级 1',
            children: [{
              id: 4,
              label: '二级 1-1',
              children: [{
                id: 9,
                label: '三级 1-1-1'
              }, {
                id: 10,
                label: '三级 1-1-2'
              }]
            }]
          }, {
            id: 2,
            label: '一级 2',
            children: [{
              id: 5,
              label: '二级 2-1'
            }, {
              id: 6,
              label: '二级 2-2'
            }]
          }, {
            id: 3,
            label: '一级 3',
            children: [{
              id: 7,
              label: '二级 3-1'
            }, {
              id: 8,
              label: '二级 3-2'
            }]
          }],
        defaultProps: {
          children: 'children',
          label: 'label'
        },
        form: {}
      }
    },
    methods: {
      getCheckedNodes() {
        console.log(this.$refs.tree.getCheckedNodes());
      },
      getCheckedKeys() {
        console.log(this.$refs.tree.getCheckedKeys());
      },
      setCheckedNodes() {
        this.$refs.tree.setCheckedNodes([{
          id: 5,
          label: '二级 2-1'
        }, {
          id: 9,
          label: '三级 1-1-1'
        }]);
      },
      setCheckedKeys() {
        this.$refs.tree.setCheckedKeys([3]);
      },
      resetChecked() {
        this.$refs.tree.setCheckedKeys([]);
      }
    }
  }
</script>
<style lang="scss" scoped>
  .input {
    width: 400px;
  }

</style>